//
//  HomeFoundSotreTableViewCell.m
//  GLGW_Shoping
//
//  Created by yang on 2018/12/27.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "HomeFoundSotreTableViewCell.h"

@implementation HomeFoundSotreTableViewCell{
    GLGWLabel * storeNameLabel;
    GLGWButton * inStoreBut;
    GLGWLabel * buyNumLabel;
    GLGWLabel * mainLabel;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        GLGWView * bankgroundView = [[GLGWView alloc] initWithInSuperView:self.contentView];
        bankgroundView.backgroundColor = [UIColor whiteColor];
        [bankgroundView setViewShadowWidth:3.0 theCornerRadius:3.0];
        [bankgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.right.equalTo(self.contentView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(self.contentView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(10));
            make.bottom.equalTo(self.contentView.mas_bottom).offset(-kHeightProportion_In_iPhoneTriploid(10));
        }];
        //
        GLGWView * leftYeView = [[GLGWView alloc] initWithFrame:CGRectMake(0, 0, kWidthProportion_In_iPhoneTriploid(6), kHeightProportion_In_iPhoneTriploid(106)) inSuperView:bankgroundView];
        leftYeView.backgroundColor = kColor_Rule_Yellow;
        UIRectCorner type = UIRectCornerTopLeft | UIRectCornerBottomLeft;
        [leftYeView setBorderWithCornerRadius:5.0 borderWidth:0 borderColor:[UIColor whiteColor] type:type];
        //
        inStoreBut = [[GLGWButton alloc] initWithTitle:@"进店" titleLableFont:SYSTEMFONT(12) titleLableColor:kColor_Rule_Yellow theCornerRadius:kHeightProportion_In_iPhoneTriploid(9) theBorderWidth:1.0 theBorderColor:kColor_Rule_Yellow backgroundColr:[UIColor whiteColor] inSuperView:bankgroundView];
        [inStoreBut mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(bankgroundView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(bankgroundView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(17));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(18)));
            make.width.equalTo(@(kWidthProportion_In_iPhoneTriploid(50)));
        }];
        //
        storeNameLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(16) theColor:kColor_Rule_Black inSuperView:bankgroundView];
//        storeNameLabel.text = @"小张店铺";
        [storeNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(bankgroundView.mas_left).offset(kWidthProportion_In_iPhoneTriploid(21));
            make.top.equalTo(bankgroundView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(15));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(22)));
            make.right.equalTo(self->inStoreBut.mas_left).offset(-kWidthProportion_In_iPhoneTriploid(10));
        }];
        //
        buyNumLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(12) theColor:[UIColor colorWithHexString:@"#666666"] inSuperView:bankgroundView];
        [buyNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(bankgroundView.mas_left).offset(kWidthProportion_In_iPhoneTriploid(23));
            make.top.equalTo(self->storeNameLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(10));
            make.right.equalTo(bankgroundView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(17)));
        }];
        //
        mainLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(12) theColor:[UIColor colorWithHexString:@"#999999"] inSuperView:bankgroundView];
        [mainLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self->storeNameLabel);
            make.right.equalTo(self->buyNumLabel);
            make.top.equalTo(self->buyNumLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(10));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(17)));
        }];
        
    }
    return self;
}

-(void)setStoreInforModel:(HomecategoryproductinfosModel_CategoryProductInfos *)storeInforModel{
    _storeInforModel = storeInforModel;
    storeNameLabel.text = _storeInforModel.shopName;
    if (_storeInforModel.orderSum == 0) {
        buyNumLabel.attributedText = [GLGWLabel addImageName:@"icon_xiaoliang_hui" theImageFram:CGRectMake(0, -3, 12, 15) theTextString:@" 月销量0单" atImageIndex:0];
    }else{
        buyNumLabel.attributedText = [GLGWLabel addImageName:@"icon_yuexiaoliang_hong" theImageFram:CGRectMake(0, -3, 12, 15) theTextString:[NSString stringWithFormat:@" 月销量%ld单",(long)_storeInforModel.orderSum] atImageIndex:0];
    }
    //
    mainLabel.text = [NSString stringWithFormat:@"主营：%@",koString(_storeInforModel.mainProduct)];
}
@end
